package win.timloong.android.a3;

import android.app.IntentService;
import android.content.ContentProvider;
import android.database.ContentObserver;
import android.databinding.DataBindingUtil;
import android.os.HandlerThread;
import android.os.SystemClock;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import win.timloong.android.a3.databinding.ActivityMainBinding;

/**
 * 支持Databinding,实现对象改动刷新界面.
 * @author tim
 * @date 2016-07-04
 */
public class MainActivity extends AppCompatActivity {

    /**
     * 界面初始化,获得Binding对象
     * @author tim
     * @param savedInstanceState 现场保护使用的Bundle.
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getContentResolver();

        Log.e("onCreate", "ok");
        final ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

        final User user = new User("Test", "User");
        binding.setUser(user);

        //子线程改动binding对象,可正常刷新界面
        new Thread() {
            @Override
            public void run() {
                SystemClock.sleep(3000);
                user.setFirstName("Change FrstName");
                binding.setUser(user);
                //增加分支测试.
                //进行分支合并测试.
            }
        }.start();

    }
}
